package cn.green.core.components.database;

import cn.green.core.components.database.entity.Database;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;

import java.util.HashMap;
import java.util.Map;

/**
 * @author wang.yishu
 * @version 1.0
 * @className DBRouter
 * @description 数据路由
 * @date 2024/11/22 16:52
 */
@Data
public class DBRouter {
    //主数据源
    @Getter
    @Setter
    private Database master;

    private Map<String, Database> databaseMap = new HashMap<>();

    public void add(Database database) {
        this.databaseMap.put(database.getSourceName(), database);
    }

    public Database get(String sourceName) {
        return this.databaseMap.get(sourceName);
    }

}
